package com.example.demo.service;

import com.alibaba.fastjson2.JSON;
import com.example.demo.model.Student;
import org.springframework.stereotype.Service;

@Service
public class StudentService {
    
//    @Autowired
//    private StudentRepository studentRepository;
    
    public void saveStudent(Student student) {
        // 数据验证
        if (student.getName() == null || student.getName().isEmpty()) {
            throw new IllegalArgumentException("学生姓名不能为空");
        }
        System.out.println(JSON.toJSONString(student));
        // 保存到数据库
//        studentRepository.save(student);
    }
}